﻿using System;
using SiteManager;
using System.Data.SqlClient;

public partial class USA_Hospitals : System.Web.UI.Page
{
    // creating an instance of manager class
    Manager _manager = new Manager(true, "ConnectionString");


    #region Pageload

    protected void Page_Load(object sender, EventArgs e)
    {
        //Page.Form.Attributes.Add("onSubmit", "javascript:showWorking()");
        Master.keywordsContent = "top hospitals, hospitals online,  hospital list, search hospitals, board certified hospitals, top hospitals in United States";
        Master.descriptionContent = "Findadoc.com offers top hospitals online, best hospitals list finder. You can find a hospital according to your requirements easily.";
        Master.titleContent = "Top Hospitals, Find A Doctor, Search Hospitals From Best Hospitals List, Top Hospitals In United States";

        Master.TdRight = false;

        Master.TopLoginIMG = false;


        if (!Page.IsPostBack)
        {
            BindTopic();
        }




    }
    public void BindTopic()
    {

        var sqlparam = new SqlParameter[0];
        var ds = CustomRepository.CustumDataSetFunction("Get_USA_Hospitals", sqlparam);


        Latest_Hospital_Repeater.DataSource = ds.Tables[0];
        Latest_Hospital_Repeater.DataBind();

        Featured_Hospital_Repeater.DataSource = ds.Tables[1];
        Featured_Hospital_Repeater.DataBind();

        Top_Hospital_Repeater.DataSource = ds.Tables[2];
        Top_Hospital_Repeater.DataBind();
        Session["Top_Hospitals"] = ds.Tables[2];

        //if(ds.Tables[3].Rows.Count>0)
        //{
        //    string countries_menu = "<ul> ";
        //    for(int i=0;i<ds.Tables[3].Rows.Count;i++)
        //    {
        //        countries_menu += " <li><a href=\"" + Session["strHttp"] + "hospital_search.aspx?c=" + ds.Tables[3].Rows[i]["Country"].ToString().Trim().Replace(" ","-").ToLower() + "\">" + ds.Tables[3].Rows[i]["Country"].ToString() + "</a></li> ";
        //    }
        //    countries_menu += " </ul>";
        //    InnerTopMenu.InnerHtml = countries_menu;
        //}
    }
    #endregion
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        string name = "", address = "", country = "", zipcode = "";

        if (txtname.Value.Trim().Replace("e.g. Hospital Name",string.Empty) != "")
        {
            name = txtname.Value.Trim().Replace("e.g. Hospital Name", string.Empty);
        }
        if (txtaddress.Value.Trim().Replace("e.g. Street Name ,State", string.Empty) != "")
        {
            address = txtaddress.Value.Trim().Replace("e.g. Street Name ,State", string.Empty);
        }

        if (txtCountry.Value.Trim().Replace("e.g. Alaska, California", string.Empty) != "")
        {
            country = txtCountry.Value.Trim().Replace("e.g. Alaska, California", string.Empty);
        }

        if (txtZipcode.Value.Trim().Replace("e.g. Zipcode", string.Empty) != "")
        {
            zipcode = txtZipcode.Value.Trim().Replace("e.g. Zipcode", string.Empty);
        }

        Session["usa_hospital_search_name"] = name;
        Session["usa_hospital_search_address"] = address;
        Session["usa_hospital_search_state"] = country;
        Session["usa_hospital_search_zipcode"] = zipcode;

        Response.Redirect(Session["strHttp"] + "hospital_search.aspx?t=usa");


    }
}